home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Found / FWExcLib / Include / FWExcRun.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-08  |  4.1 KB  |  138 lines  |  [TEXT/MPS ]

  1. #ifndef FWEXCRUN_H
  2. #define FWEXCRUN_H
  3.  
  4. //========================================================================================
  5. //
  6. //    File:                FWExcRun.h
  7. //    Release Version:    $ 1.0d11 $
  8. //
  9. //    Copyright:    (c) 1993, 1995 by Apple Computer, Inc., all rights reserved.
  10. //
  11. //========================================================================================
  12.  
  13. #ifndef FW_NATIVE_EXCEPTIONS
  14.  
  15. #ifndef   FWEXCEPT_H
  16. #include "FWExcept.h"
  17. #endif
  18.  
  19. #ifndef   FWDELSTA_H
  20. #include "FWDelSta.h"
  21. #endif
  22.  
  23. #ifndef   FWEXCTAS_H
  24. #include "FWExcTas.h"
  25. #endif
  26.  
  27. #ifdef FW_DEBUG
  28. #include <stdio.h>
  29. #endif
  30.  
  31. #if FW_LIB_EXPORT_PRAGMAS
  32. #pragma lib_export on
  33. #endif
  34.  
  35. class FW_CLASS_ATTR FW_CPrivTryBlockContext;
  36. class FW_CLASS_ATTR _FW_CAutoDestructObject;
  37.  
  38. #ifdef FW_USE_NEW_HELPER
  39. class FW_CLASS_ATTR FW_CPrivNewHelper;
  40. #endif
  41.  
  42. //========================================================================================
  43. //    Functions for "unexpected" and "terminate"
  44. //
  45. //        See ARM, Section 15.6
  46. //========================================================================================
  47.  
  48. #ifndef __BORLANDC__
  49. extern void terminate();
  50. extern void unexpected();
  51.  
  52. extern PFV set_terminate(PFV);
  53. extern PFV set_unexpected(PFV);
  54. #endif
  55.  
  56. //========================================================================================
  57. // CLASS FW_CPrivExceptionRuntime
  58. //========================================================================================
  59.  
  60. class FW_CLASS_ATTR FW_CPrivExceptionRuntime
  61. {
  62. public:
  63.     enum
  64.     {
  65.         kDefaultExceptionBufferSize = 128
  66.             // Exception buffer size in bytes.
  67.             // This limits size of largest exception object that may be thrown
  68.     };
  69.     
  70.     static void Initialize(FW_SPrivExceptionGlobals& globals);
  71.     static void Terminate();
  72.  
  73.     static void Throw(const _FW_XException & thrownException);
  74.     static void ThrowSame();
  75.     static void ThrowConstructor(_FW_XException & thrownException);
  76.     static void ThrowSameConstructor();
  77.     static void CaughtException(FW_SPrivExceptionGlobals& globals, _FW_XException * caughtException);
  78.     static void CaughtEverythingException(FW_SPrivExceptionGlobals& globals);
  79.     static void CaughtNoInstanceException(FW_SPrivExceptionGlobals& globals);
  80.     static void CaughtReferenceException(FW_SPrivExceptionGlobals& globals);
  81.     static void KeepThrowing(FW_SPrivExceptionGlobals& globals);
  82.     static void CatchCleanup(FW_SPrivExceptionGlobals& globals);
  83.     static void ResetExceptionBufferSize(size_t newSize);
  84.     static PFV SetTerminate(PFV);
  85.     static PFV SetUnexpected(PFV);
  86.     
  87.     static void EndConstructor(_FW_CAutoDestructObject *object, size_t size);
  88.     
  89. #ifdef FW_DEBUG
  90.     static    FW_ClassInfoPtr SetBreakOnThrow(FW_ClassInfoPtr breakExceptionKind = NULL);
  91.     static    FW_ClassInfoPtr GetBreakOnThrow();
  92. #endif
  93.  
  94. private:
  95.     static void DeleteObjectsInContextAndJump(FW_SPrivExceptionGlobals& globals, FW_CPrivTryBlockContext * FWTryBlo);
  96.     static void PrimitiveThrow(const _FW_XException & thrownException);
  97.     static void PrimitiveThrowSame();
  98.  
  99. };
  100.  
  101. //========================================================================================
  102. // CLASS FW_CPrivExceptionRuntime INLINE Functions
  103. //========================================================================================
  104.  
  105. #ifdef FW_DEBUG
  106. inline FW_ClassInfoPtr FW_CPrivExceptionRuntime::SetBreakOnThrow(FW_ClassInfoPtr breakExceptionKind)
  107. {
  108.     FW_ClassInfoPtr previous = FW_CExceptionTaskGlobals::GetExceptionGlobals().gBreakExceptionKind;
  109.     FW_CExceptionTaskGlobals::GetExceptionGlobals().gBreakExceptionKind = breakExceptionKind;
  110.     return previous;
  111. }
  112. #endif
  113.  
  114. #ifdef FW_DEBUG
  115. inline FW_ClassInfoPtr FW_CPrivExceptionRuntime::GetBreakOnThrow()
  116. {
  117.     return FW_CExceptionTaskGlobals::GetExceptionGlobals().gBreakExceptionKind;
  118. }
  119. #endif
  120.  
  121. //========================================================================================
  122. // CLASS FW_CPrivExceptionRuntime INLINE Functions (Platform-independent Versions)
  123. //========================================================================================
  124.  
  125. inline void FW_CPrivExceptionRuntime::CatchCleanup(FW_SPrivExceptionGlobals& globals)
  126. {
  127.     globals.gCaughtException = NULL;
  128.     globals.gThrownException = NULL;
  129. }
  130.  
  131. #if FW_LIB_EXPORT_PRAGMAS
  132. #pragma lib_export off
  133. #endif
  134.  
  135. #endif // FW_NATIVE_EXCEPTIONS
  136.  
  137. #endif
  138.